package com.ngc.mall.common.interceptor;

import com.ngc.mall.common.configure.interceptor.PermissionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {
    @Bean
    public PermissionInterceptor wxAuthInterceptor(){
        return new PermissionInterceptor();
    }
//    public void configurePathMatch(PathMatchConfigurer configurer){
//        configurer.addPathPrefix("/api",(t) -> t.isAnnotationPresent(RestController.class)||t.isAnnotationPresent(Controller.class));
//    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(wxAuthInterceptor()).addPathPatterns("/**").excludePathPatterns("/payment/wx/notify","/login","/token/*","/wechat/token/**");
//        registry.addInterceptor(wxAuthInterceptor()).addPathPatterns("/user/*","order/*","integral/*","coupon/*","payment/*");

    }
}
